#!/usr/local/bin/jython
# encoding: utf-8
"""
csvtoexcel.py

Created by wangzheng on 2008-04-09.
Copyright (c) 2008 sina. All rights reserved.
"""

from poi import POI
import datetime
import os,sys

def convert(filename):
    data = []
    for line in open(filename):
        data.append(
            tuple( [{'v':unicode(i,'utf8')} for i in line.split()] )
        )
    return data

def main(filename):
    output='%s.xls'%( os.path.splitext(filename)[0] )
    fname='blank.xls'
    condata = convert(filename)
    data = [condata,]
    poi=POI(fname,output,data)
    poi.save()
    

if __name__ == '__main__':
    args=sys.argv
    if len(args)==1:
        print '''
csvtoexcel.py [option] file
Options and arguments (and corresponding environment variables):
file   : csv filename
'''
    else:
        main(args[1].strip())